package cn.heyige.backend.dto;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Map;

@Data
public class SystemMonitorDto {
    
    @Setter
    @Getter
    public static class SystemStatusResponse {
        // 总内存（字节）
        private Long totalMemory;
        // 空闲内存（字节）
        private Long freeMemory;
        // 已使用内存（字节）
        private Long usedMemory;
        // 最大内存（字节）
        private Long maxMemory;
        // 可用处理器数量
        private Integer availableProcessors;
        // 系统平均负载
        private Double systemLoadAverage;
        // JVM启动时间
        private LocalDateTime jvmStartTime;
        // JVM运行时间
        private Duration jvmUptime;
        // 应用名称
        private String applicationName;
        // 应用版本
        private String applicationVersion;
        // 服务器时间
        private LocalDateTime serverTime;

    }
    
    @Setter
    @Getter
    public static class AiServiceStatusResponse {
        private ServiceStatus deepSeek;
        private ServiceStatus zhipu;
        private ServiceStatus qwen;
        private Boolean allConnected;
        private LocalDateTime checkTime;

    }

    @Setter
    @Getter
    public static class ServiceStatus {
        private String name;
        private Boolean connected;
        private LocalDateTime lastCheckTime;
    }
    
    @Setter
    @Getter
    public static class SystemStatisticsResponse {
        // 堆内存已使用（字节）
        private Long heapMemoryUsed;
        // 堆内存最大（字节）
        private Long heapMemoryMax;
        // 非堆内存已使用（字节）
        private Long nonHeapMemoryUsed;
        // 非堆内存最大（字节）
        private Long nonHeapMemoryMax;
        // 线程数量
        private Integer threadCount;
        // 峰值线程数量
        private Integer peakThreadCount;
        // 守护线程数量
        private Integer daemonThreadCount;
        // 已加载类数量
        private Integer loadedClassCount;
        // 总共加载类数量
        private Long totalLoadedClassCount;
        // 已卸载类数量
        private Long unloadedClassCount;
        // 编译时间（毫秒）
        private Long compilationTime;
        // 垃圾回收信息
        private Map<String, Long> garbageCollectionInfo;
        // 统计时间
        private LocalDateTime statisticsTime;
    }

    @Setter
    @Getter
    public static class HealthCheckResponse {
        private Boolean healthy;
        private LocalDateTime checkTime;
        private String details;
        private Map<String, Boolean> componentStatus;
    }
    
    @Setter
    @Getter
    public static class SystemInfoResponse {
        private SystemStatusResponse status;
        private AiServiceStatusResponse aiServiceStatus;
        private SystemStatisticsResponse statistics;
        private HealthCheckResponse healthCheck;
        private LocalDateTime fetchTime;
    }
}